# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=dontgo403
pkgver=v1.1.8.r1.g5629009
pkgrel=1
epoch=2
pkgdesc='Tool to bypass 40X response codes..'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-webapp' 'blackarch-exploitation'
        'blackarch-scanner')
url='https://github.com/devploit/dontgo403'
license=('Apache')
depends=('glibc')
makedepends=('git' 'go')
source=("git+https://github.com/devploit/$pkgname.git")
sha256sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd $pkgname

  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w" \
    -o $pkgname .

}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a $pkgname payloads "$pkgdir/usr/share/$pkgname/"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec ./$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

